package com.hyzh.latte.sand.socket;

import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;


/**
 * @author: songkui
 * @since: 2024/3/21 0:14
 */
@Component
@Order(3)
@Slf4j
@AllArgsConstructor
public class SandSocketStartInitialize implements ApplicationRunner {

    private final SandSocketConnectHandler sandSocketConnectHandler;

    private final SandSocketUserValidHandler sandSocketUserValidHandler;
    private final SandSocketCloseHandler sandSocketCloseHandler;

    @Override
    public void run(ApplicationArguments args) throws Exception {
//        MochaWebSocket.builder(MochaWSMetadataBuilder.builder()
//                .socketCloseHandler(sandSocketCloseHandler)
//                .socketConnectHandler(sandSocketConnectHandler)
//                .socketUserValidHandler(sandSocketUserValidHandler)
//                .initHandler(SandCommandType.getMap(), "com/hyzh/latte/sand/socket/handler"))
//                .start(19000, "::0");

        SanderHandlerBuilder.builder()
                .socketCloseHandler(sandSocketCloseHandler)
                .socketConnectHandler(sandSocketConnectHandler)
                .socketUserValidHandler(sandSocketUserValidHandler)
                .initHandler(SandCommandType.getMap(), "com/hyzh/latte/sand/socket/handler")
                .start(19000, "::0");


    }


}
